package lq3194;

import java.util.Scanner;
import java.util.Stack;

/*
lq3194
输入1：
123456789
输出1：
1243989
输入2：
8976457333844
输出2：
8994344833
*/
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String num = sc.nextLine();
		Stack<Integer> s = new Stack<>();
		
		char[] arr = num.toCharArray();
		
		for(int i = 0; i < arr.length; i++) {
            if(arr[i] == '3') {
                s.push(i);
            }
            if(arr[i] == '4') {
                if(!s.empty()) {
                    int topIndex = s.pop();
                    arr[topIndex] = '4';
                    arr[i] = '3';
                }
            }
            if(arr[i] == '6') {
                arr[i] = '9';
            }
        }
		
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<arr.length;i++) {
			if(arr[i]=='5'||arr[i]=='7')
				continue;
			sb.append(arr[i]);
		}
		
		System.out.print(sb.toString());

	}

}
